home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / prg_bar.exe / TPROGBAR.H < prev   
C/C++ Source or Header  |  1992-08-29  |  2KB  |  58 lines

  1. #if !defined( __TPROGBAR_H )
  2. #define __TPROGBAR_H
  3.  
  4. #if !defined( __MATH_H )
  5. #include <math.h>
  6. #endif       // __MATH_H
  7.  
  8. #define DISPLAYLEN  51      // Length (width) of calculator display
  9.  
  10. enum TCalcState { csFirst = 1, csValid, csError };
  11.  
  12. const int cmCalcButton  = 200;
  13.  
  14. class TProgressBar : public TView
  15. {
  16.     protected:
  17.         char          backChar;            // background character
  18.         char          percChar;            // percentage character
  19.         char *        bar;                // thermometer bar
  20.         unsigned int  maxWidth;            // maximum width of thermometer bar
  21.         unsigned int  oldWidth;            // previous width
  22.         unsigned int  curWidth;            // current width of percentage bar
  23.         double        chPercent;        // percent per character
  24.         unsigned long maxIter;            // maximum iteration
  25.         unsigned long curIter;            // current iteration
  26.         unsigned int  oldPercent;        // old percentage complete
  27.         unsigned int  curPercent;        // current percentage complete
  28.  
  29.         void calcPercent ( );            // calculate new percentage
  30.  
  31. public:
  32.      TProgressBar(TRect& r, unsigned long iters );
  33.      ~TProgressBar();
  34.      virtual void handleEvent(TEvent& event);
  35.      virtual void draw();
  36.         virtual void term ( );            // clear the thermometer bar display
  37.  
  38.         inline unsigned long getMaxIter ( );    // get the maximum iteration
  39.         inline unsigned long getCurIter ( );    // get the current iteration
  40.  
  41.         // change the percentage ( calls the update function )
  42.         void setMaxIter ( unsigned long newMax );    // set the maximum iteration
  43.         void setCurIter ( unsigned long newCur );    // set the current iteration
  44. private:
  45.      TCalcState status;
  46.      virtual void mainProcess( void );
  47. };
  48.  
  49. #endif      // __TPROGBAR_H
  50. /*
  51. class spreadIt : public TProgressBar
  52. {
  53.      spreadIt(TRect& r, unsigned long iters ) :
  54.         TProgressBar( r , iters ){};
  55.      virtual void mainProcess( void );
  56. };
  57. */
  58.